/*
 * To change this template, choose Tool

@Override
public void addColumn(TableColumn tc) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void removeColumn(TableColumn tc) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void moveColumn(int i, int i1) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void setColumnMargin(int i) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getColumnCount() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public Enumeration<TableColumn> getColumns() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getColumnIndex(Object o) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public TableColumn getColumn(int i) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getColumnMargin() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getColumnIndexAtX(int i) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getTotalColumnWidth() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void setColumnSelectionAllowed(boolean bln) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public boolean getColumnSelectionAllowed() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int[] getSelectedColumns() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public int getSelectedColumnCount() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void setSelectionModel(ListSelectionModel lsm) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public ListSelectionModel getSelectionModel() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void addColumnModelListener(TableColumnModelListener tl) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void removeColumnModelListener(TableColumnModelListener tl) {
throw new UnsupportedOperationException("Not supported yet.");
}
} | Templates
 * and open the template in the editor.
 */

/*
 * todotask.java
 *
 * Created on 20-jun-2011, 18:53:48
 */
package todotask.view;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import todotask.Adapters.NuevaTareaAdapter;
import todotask.Database.Data;
import todotask.entities.Category;
import todotask.entities.Status;
import todotask.entities.Task;
import todotask.model.TaskCellEditor;
import todotask.Renderer.TaskCellRender;
import todotask.model.TaskTableModel;

/**
 *
 * @author dakota
 */
public class TodoTask extends javax.swing.JPanel {

    private static TodoTask este;
    private JFrame parent;
    private Data d;

    /** Creates new form todotask */
    public TodoTask() {
        initComponents();
        initMyComponents();
    }

    public TodoTask(JFrame parent) {
        this.parent = parent;
        initComponents();
        initMyComponents();
    }

    private void initMyComponents() {
        d = new Data();
        este = this;
        //Dando funcionalidad a la Tabla
        TaskCellRender tcr = new TaskCellRender();
        tableTasks.setDefaultRenderer(Task.class, tcr);
        tableTasks.setRowHeight(116);
        TaskCellEditor tce = new TaskCellEditor();
        tableTasks.setDefaultEditor(Task.class, tce);
        tableTasks.setTableHeader(null);

        //Dando Funcionalidad al boton de añadir Tarea
        newTask.addMouseListener(new NuevaTareaAdapter(parent));

        //Aqui se deberia de llamar a un metodo, todavia por implementar, para cargar desde
        //la base de datos todas las tareas NO FINALIZADAS
        List<Task> tasks = new ArrayList<Task>();
        try {
            Task[] ListTasks = d.getTaskPending();
            tasks.addAll(Arrays.asList(ListTasks));
        } catch (SQLException ex) {
            //Llamar a la clase de gestor de errores
            Logger.getLogger(TodoTask.class.getName()).log(Level.SEVERE, null, ex);
        }

        tableTasks.setModel(new TaskTableModel(tasks));
    }

    public static void main(String args[]) {
        lookAndFeel();
        JFrame fr = new JFrame();
        fr.add(new TodoTask());
        fr.setVisible(true);
        fr.setSize(350, 500);
        fr.setLocationRelativeTo(null);
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    private static void lookAndFeel() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel4 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        newTask = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableTasks = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        newTask.setText("+");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(newTask, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(newTask)
                .addContainerGap())
        );

        jPanel1.setBackground(new java.awt.Color(255, 128, 0));

        tableTasks.setModel(new TaskTableModel());
        tableTasks.setColumnSelectionAllowed(true);
        jScrollPane1.setViewportView(tableTasks);
        tableTasks.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
        );

        jButton2.setText("Pending");

        jButton3.setText("Complete");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton2)
                .addGap(18, 18, 18)
                .addComponent(jButton3)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton newTask;
    private javax.swing.JTable tableTasks;
    // End of variables declaration//GEN-END:variables
}
